<?php

	class Tlb{
		
		var $t = 'f';
		
		// op is string function or obj options
		var $o = '';
		
		function option($n){
			if(!$this->isMenu()) $this->toMenu();
			if(!isset($this->o->$n)) $this->o->$n = new Tlb;
			return $this->o->$n;
		}
		
		function insertBefore($key, $n, $tlb){
			if(!$this->isMenu()) $this->toMenu();
			$this->o->insertBefore($key, $n, $tlb);
		}
		
		function toFunction($func, $doif='', $showif=''){
			$this->t = 'f';
			$this->o = $func;
			if($doif) $this->e = $doif;
			if($showif) $this->d = $showif;
		}
		
		function toMenu(){
			$this->t = 'm';
			$this->o = new jso;
		}
		
		function isMenu(){
			return $this->t == 'm';
		}
		
		function to_js(){
			return json_encode($this->o);
		}
	}

